package com.oa.hyperion.repository.assets;

import com.oa.hyperion.entity.assets.AssetsAllocation;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 资产调拨
 * author yuanchongwei
 * date 2022-1-18
 */
public interface AssetsAllocationMapper {
    /**
     * 新增
     * @param assetsAllocation
     */
    @Insert("insert into " +
            "assets_allocation(asset_id,transfer_out,out_user,out_date,transfer_in,in_user,in_date,reason,handler) " +
            "values(#{assetId},#{transferOut},#{outUser},#{outDate},#{transferIn},#{inUser},#{inDate},#{reason},#{handler})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    public void insert(AssetsAllocation assetsAllocation);

    /**
     * 查询所有资产调拨信息
     * @return 资产调拨信息
     */
    @Select("select * from assets_allocation")
    public List<AssetsAllocation> getAllAllocation();

    /**
     * 查询
     * 根据资产id查询资产调拨信息
     * @param assetId 资产id
     * @return 资产调拨信息
     */
    @Select("select * from assets_allocation where asset_id=#{assetId}")
    public List<AssetsAllocation> getAssetsAllocationByAssetId(int assetId);

    /**
     * 查询
     * 根据拨出部门查询资产调拨信息
     * @param transfer_out 拨出部门
     * @return 资产调拨信息
     */
    @Select("select * from assets_allocation where transfer_out=#{transferOut}")
    public List<AssetsAllocation> getAssetsAllocationByTransferout(int transfer_out);

    /**
     * 查询
     * 根据拨入部门查询资产调拨信息
     * @param transfer_in 拨入部门
     * @return 资产调拨信息
     */
    @Select("select * from assets_allocation where transfer_in=#{transferIn}")
    public List<AssetsAllocation> getAssetsAllocationByTransferin(int transfer_in);

    /**
     * 查询
     * 根据经办人查询资产调拨信息
     * @param handler 经办人
     * @return 资产调拨信息
     */
    @Select("select * from assets_allocation where handler=#{handler}")
    public List<AssetsAllocation> getAssetsAllocationByHandler(String handler);

}
